import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data_source = '.\\test3\\ExtraExercise\\MultipleLinearRegression\\ex1data2.txt'
data = pd.read_csv(data_source,header=None)
data = (data - data.mean())/data.std()#single feature可以不用归一化
data.insert(0, 'Ones', 1)#把b凑到矩阵里，在梯度下降法也可以这样


n = data.shape[1]
x_train = np.matrix(data.iloc[:,0:n-1])
y_train = np.matrix(data.iloc[:,n-1]).T#matrix构建的是一个2D矩阵
theta = np.linalg.inv(x_train.T * x_train) * x_train.T * y_train
print(theta)

